package com.ruoyi.system.utils;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.mail.javamail.MimeMessageHelper;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

/**
 * @author xy
 * @version 1.0
 * @description: 邮箱工具类
 * @date 2024/7/5 15:43
 */
public class QQEmail {
    public static void sendEmail(JavaMailSender javaMailSender,String MailFrom, String MailTo, String subject, String body) throws MessagingException {
        MimeMessage message = javaMailSender.createMimeMessage();
        MimeMessageHelper helper = new MimeMessageHelper(message, true);
        helper.setFrom(MailFrom);
        helper.setTo(MailTo);
        helper.setSubject(subject);
        helper.setText(body, true);
        javaMailSender.send(message);
    }
}
